myApp.controller('navbarMenu', ['$scope', '$location', '$employee', '$http', function($scope, $location, $employee, $http) {

	$scope.logout = function() {

		var data = {};

		var postCfg = {
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			transformRequest: function(data) {
				return $.param(data);
			}
		};

		$http.post('logout', data, postCfg).then(function successCallback(response) {
			$employee.currentEmployee = {"Nothing": "Nothing"};
			$location.path('/login'); 

			console.log("ok：" + response);
		}, function errorCallback(response) {
			alert("登出操作失败!");
			console.log("fail：" + response);
		});
	}

}]);


myApp.controller('home', ['$scope', '$location', '$employee', function($scope, $location, $employee) {

	if ($employee.currentEmployee.Nothing === "Nothing") {
		$location.path('/login');
	}

	$scope.goodsIM = false;
	$scope.saleIM = false;
	$scope.purchaseIM = false;
	$scope.shopIM = false;
	$scope.stockIM = false;
	$scope.customerIM = false;
	$scope.financeIM = false;
	$scope.decisionIM = false;
	$scope.adminIM = false;
	$scope.superAdminIM = false;

	var jurisdictionId = $employee.currentEmployee.jurisdictionId.split(",");
	for (var i = 0; i < jurisdictionId.length; i++) {
		if (jurisdictionId[i] == 1) {
			$scope.goodsIM = true;
		}
		if (jurisdictionId[i] == 2) {
			$scope.saleIM = true;
		}
		if (jurisdictionId[i] == 3) {
			$scope.purchaseIM = true;
		}
		if (jurisdictionId[i] == 4) {
			$scope.shopIM = true;
		}
		if (jurisdictionId[i] == 5) {
			$scope.stockIM = true;
		}
		if (jurisdictionId[i] == 6) {
			$scope.customerIM = true;
		}
		if (jurisdictionId[i] == 7) {
			$scope.financeIM = true;
		}
		if (jurisdictionId[i] == 8) {
			$scope.decisionIM = true;
		}
		if (jurisdictionId[i] == 9 || jurisdictionId[i] == 10) {
			$scope.adminIM = true;
		}
		if (jurisdictionId[i] == 10) {
			$scope.superAdminIM = true;
		}
	}

}]);